Here's one possible way to queue up and sequentially play a number of internal soundfiles. Although it uses parent/child scripting it's very straightforward. Paste the following handlers into a parent script window and then check that linebreaks made it across the web as expected:
-- Parent script name: "Jukebox class"
property myChannel, myPlayList, myCurrentSound
on new me, whatChannel, whatSounds
set myChannel to whatChannel
set myPlayList to whatSounds
set myCurrentSound to ""
add the actorList, me
return me
end
on stepFrame me --exitframe?
if count(myPlayList) = 0 then exit
if NOT soundBusy(myChannel) then
set myCurrentSound to getAt(myPlayList, 1)
puppetSound myChannel, myCurrentSound
deleteAt(myPlayList, 1)
end if
end
on AddSound me, whatSound
add myPlayList, whatSound
end
on GetCurrentSound me
if NOT soundBusy(myChannel) then set myCurrentSound to ""
return myCurrentSound
end
If you copy and paste the above into a parent script, then you can use something like the following in a movie script to initialize it (arbitrary sound channels and members are used here):
on startMovie
set the actorList to []
global gJukebox
set gJukeBox to new (script "Jukebox Class", 2, [member "mazurka" of castLib "audio", member "conjunto" of castLib "audio"])
When the movie starts then the sound named "mazurka" will play, then the sound named "conjunto". You can add sounds and query the current sound with things like the following, from the Message Window:
showglobals
-- Global Variables --
version = "6.0"
gJukebox = <offspring "Jukebox class" 2 10d1e68>
put GetCurrentSound(gJukebox)
-- (member "mazurka" of castLib "audio")
AddSound(gJukebox, member "slow tango" of castLib "audio")
As with all Lingo technotes, this will not be appropriate for every project, but it does show a path that can be used in some projects. The scripting can also be used as a springboard for your own work... it is just a suggestion.